package practicedemo39;

public class practicedemo39 {
    public static void main(String[] args) {
        int[] arr = new int[] {1,2,3,4};
        System.out.println(method(arr));
    }
    public static String method (int[] arr){
        if (arr == null){
            return "";
        }
        if (arr.length == 0){
            return "[]";
        }

        String result = "[";

        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1){
                result = result + arr[i];
                break;
            }
            result = result + arr[i] + ',';
        }
        result = result + ']';
        return result;
    }
}
